home *** CD-ROM | disk | FTP | other *** search
- /*
- NIDomain.h
- NetInfo Domain Class
- Copyright (c) 1994, NeXT Computer, Inc.
- All rights reserved.
- */
-
- #ifndef STRICT_OPENSTEP
-
- #import <Foundation/NSArray.h>
- #import <Foundation/NSString.h>
- #import <Foundation/NSDate.h>
- #import <Foundation/NSDictionary.h>
- #import <Foundation/NSLock.h>
- #import <Foundation/NSHost.h>
- #import <NIAccess/NIServer.h>
- @class NIDirectory;
-
- @interface NIDomain : NSObject
- {
- @private
- NSString *domainName;
- NIDomain *parentDomain;
- NSMutableDictionary *childDict;
- NSMutableArray *childInfo;
- NSMutableArray *childDomains;
- NSMutableArray *childNames;
- NSMutableArray *childIsLocal;
- NSHost *masterHost;
- NIServer *master;
- NSString *masterName;
- NSString *masterHostName;
- NSString *masterTag;
- NSMutableArray *serverInfo;
- NSMutableArray *serverList;
- NSTimeInterval readTimeout;
- NSTimeInterval writeTimeout;
- BOOL writeRequired;
- BOOL authenticatedAsRoot;
- BOOL authenticated;
- NSString *authUser;
- void *handle;
- NSLock *directoryCacheLock;
- NSMutableDictionary *directoryCache;
- BOOL directoryCacheEnabled;
- BOOL isRootDomain;
- BOOL haveCheckedIsRootDomain;
- id reserved;
- }
-
- /*
- * Class Methods
- */
-
- /*
- * Domain cache management
- * If enabled, only one object representing each domain is created, and
- * a shared instance is returned by all methods that return a domain.
- * Note that this will affect timeout / needwrite settings, as well
- * as forced connections made with connectToMaster: and connectToServer:
- */
- + (void)setDomainCacheEnabled:(BOOL)flag;
- + (BOOL)isDomainCacheEnabled;
- + (void)flushDomainCache;
-
- /*
- * Domains
- */
- + (NIDomain *)localDomain;
- + (NIDomain *)rootDomain;
-
- + (NIDomain *)domainWithName:(NSString *)name
- relativeTo:(NIDomain *)relative
- readTimeout:(NSTimeInterval)readTime
- writeTimeout:(NSTimeInterval)writeTime
- writeRequired:(BOOL)mustWrite;
-
- + (NIDomain *)domainWithName:(NSString *)name;
-
- + (NIDomain *)domainWithName:(NSString *)name
- relativeTo:(NIDomain *)relative;
-
- + (NIDomain *)domainWithName:(NSString *)name
- readTimeout:(NSTimeInterval)readTime
- writeTimeout:(NSTimeInterval)writeTime
- writeRequired:(BOOL)mustWrite;
-
- + (NIDomain *)domainWithServer:(NIServer *)server
- readTimeout:(NSTimeInterval)readTime
- writeTimeout:(NSTimeInterval)writeTime;
-
- + (NIDomain *)domainWithServer:(NIServer *)server;
-
- + (BOOL)domainExistsWithName:(NSString *)name;
-
- /*
- * Instance methods
- */
-
- /*
- * Initialization
- */
- - (NIDomain *)initWithName:(NSString *)name
- relativeTo:(NIDomain *)relative
- readTimeout:(NSTimeInterval)readTime
- writeTimeout:(NSTimeInterval)writeTime
- writeRequired:(BOOL)mustWrite;
-
- - (NIDomain *)initWithName:(NSString *)name;
-
- - (NIDomain *)initWithName:(NSString *)name
- relativeTo:(NIDomain *)relative;
-
- - (NIDomain *)initWithName:(NSString *)name
- readTimeout:(NSTimeInterval)readTime
- writeTimeout:(NSTimeInterval)writeTime
- writeRequired:(BOOL)mustWrite;
-
- - (NIDomain *)initWithServer:(NIServer *)server
- readTimeout:(NSTimeInterval)readTime
- writeTimeout:(NSTimeInterval)writeTime;
-
- - (NIDomain *)initWithHandle:(void *)d
- readTimeout:(NSTimeInterval)readTime
- writeTimeout:(NSTimeInterval)writeTime
- writeRequired:(BOOL)mustWrite;
-
- /*
- * Authentication.
- *
- * Note that users are represented by their name, rather than as an
- * NSUserAccount, since NSUserAccount only works for users known to the
- * local system, but NetInfo users may be in a remote domain and therefore
- * unknown locally.
- */
- - (BOOL)authenticateAsUserName:(NSString *)userName
- password:(NSString *)pw;
- - (void)deauthenticate;
-
- /*
- * Get the current user.
- */
- - (NSString *)userName;
-
- /*
- * Get authentication status.
- */
- - (BOOL)isAuthenticatedAsUserName:(NSString *)userName;
- - (BOOL)isAuthenticatedAsRoot;
-
- /*
- * Check the status of the connection to this domain.
- * Returns YES if any server is alive.
- */
- - (BOOL)isAlive;
-
- /*
- * Force the connection to switch to the specified server.
- * Note this will affect shared instances (if Domain cacheing is enabled).
- */
- - (BOOL)connectToServer:(NIServer *)server;
-
- /*
- * Check the status of the master.
- */
- - (BOOL)masterIsAlive;
-
- /*
- * Force the connection to switch to the domain's master server.
- * Note this will affect shared instances (if Domain cacheing is enabled).
- */
- - (BOOL)connectToMaster;
-
- /*
- * Determine if the current connection is to the domain's master.
- */
- - (BOOL)isConnectedToMaster;
-
- /*
- * Servers for this domain.
- */
- - (NIServer *)master;
- - (NSString *)masterName;
- - (NSString *)masterHostName;
- - (NSString *)masterTag;
- - (NSArray *)servers;
- - (NSArray *)clones;
- - (NIServer *)currentServer;
- - (void)flushServerCache;
-
- /*
- * Get the domain's absolute name. (Starts at "/")
- */
- - (NSString *)name;
-
- /*
- * Get a child's domain's name relative to this domain.
- */
- - (NSString *)nameForChild:(NIDomain *)child;
-
- /*
- * Get the domain's name relative to it's parent domain.
- * The root domain's relative name is "/".
- */
- - (NSString *)relativeName;
-
- /*
- * Set the read timeout. 0 means that read operations never time out.
- * Note this will affect shared instances (if Domain cacheing is enabled).
- */
- - (void)setReadTimeout:(NSTimeInterval)readTime;
-
- /*
- * Get the current read timeout value.
- */
- - (NSTimeInterval)readTimeout;
-
- /*
- * Set the write timeout. 0 means that write operations never time out.
- * Note this will affect shared instances (if Domain cacheing is enabled).
- */
- - (void)setWriteTimeout:(NSTimeInterval)writeTime;
-
- /*
- * Get the current write timeout value.
- */
- - (NSTimeInterval)writeTimeout;
-
- /*
- * Force the connection to lock onto the master if flag is true,
- * or release this requirement if flag is false.
- * Note this will affect shared instances (if Domain cacheing is enabled).
- */
- - (BOOL)writeRequired:(BOOL)flag;
-
- /*
- * Get the current setting of the writeRequired flag.
- */
- - (BOOL)isWriteRequired;
-
- /*
- * Open a connection to a relative domain.
- */
- - (NIDomain *)relativeDomainNamed:(NSString *)relativeName;
- - (BOOL)hasRelativeDomainNamed:(NSString *)relativeName;
-
- /*
- * Open a connection to this a domain's parent domain.
- */
- - (NIDomain *)parentDomain;
- - (BOOL)hasParentDomain;
- /* isRootDomain is just !hasParentDomain */
- - (BOOL)isRootDomain;
-
- /*
- * Open a connection to a domain's child domain with a specific name.
- */
- - (NIDomain *)childDomainNamed:(NSString *)name;
- - (BOOL)hasChildDomainNamed:(NSString *)name;
-
- /*
- * Child domains.
- */
- - (BOOL)hasChildren;
- - (unsigned)numberOfChildren;
- - (NSArray *)childDomains;
- - (NSArray *)childDomainsAreLocal;
- - (NSArray *)childDomainNames;
- - (void)flushChildCache;
-
- /*
- * Directory cache management.
- * If enabled, each domain will cache directory objects, so that only one
- * shared instance of each directory will exist.
- */
- - (void)setDirectoryCacheEnabled:(BOOL)flag;
- - (BOOL)isDirectoryCacheEnabled;
- - (void)flushDirectoryCache;
-
- /*
- * Get a domain's root directory.
- */
- - (NIDirectory *)rootDirectory;
-
- /*
- * Get a directory by ID number.
- */
- - (NIDirectory *)directoryWithNumber:(unsigned int)number;
- - (BOOL)hasDirectoryWithNumber:(unsigned int)number;
-
- /*
- * Get a directory with a specified pathname.
- */
- - (NIDirectory *)directoryWithPath:(NSString *)path;
- - (BOOL)hasDirectoryWithPath:(NSString *)path;
-
- /*
- * Get a list of all directory ID numbers.
- */
- - (NSArray *)directoryNumbers;
-
- /*
- * Utility methods
- */
-
- /*
- * Break a string specifying a serves property (name/tag)
- * into it's two components.
- */
- - (BOOL)getName:(NSString **)nameString
- tag:(NSString **)tagString
- fromServes:(NSString *)servesString;
-
- /*
- * Get an array of entries for all servers for child domains.
- * The array contains an array for each child server.
- * The child server array contains 4 strings:
- * hostname, address, domain name, and tag.
- * The components can be addressed by NIServerInfoIndex enums:
- * NIServerInfoHostNameIndex, NIServerInfoAddressIndex,
- * NIServerInfoDomainNameIndex, and NIServerInfoTagIndex.
- */
- - (NSArray *)childInfo;
-
- /*
- * Get netinfo(3) library handle.
- * Use of the handle should be avoided if at all possible.
- * If the handle is used to make netinfo(3) library calls, and the
- * application is multi-threaded, then the call should be protected using
- * NINetInfo "lock" and "unlock". For example:
- *
- * ni_status status;
- * NINetInfo *ni = [NINetInfo netinfo];
- * void *handle = [aDomain handle];
- * [ni lock];
- * status = ni_read(handle, ...);
- * [ni unlock];
- *
- */
- - (void *)handle;
-
- @end
-
- #endif STRICT_OPENSTEP
-